package com.msf.tutorial.java8.chapter4;

import com.msf.tutorial.java8.Apple;

import java.util.Comparator;

/**
 * 方法引用
 */
public class C01Exam {

    public static void main(String[] args) {

        // 曾经
        Comparator<Apple> c0 = new Comparator<Apple>() {
            @Override
            public int compare(Apple a, Apple b) {
                return a.getWeight().compareTo(b.getWeight());
            }
        };

        // Lambda 表达式
        Comparator<Apple> c1 = (a, b) -> a.getWeight().compareTo(b.getWeight());

        // 方法引用
        Comparator<Apple> c2 = Comparator.comparing(Apple::getWeight);

        // 方法引用
        Comparator<String> c3 = String::compareTo;

    }

}
